package com.paic.mhis.hcpms.quota.intergration.sao.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;

import com.paic.mhis.hcpms.quota.intergration.sao.FwaMonthlyReportSao;
import com.paic.pafa.app.integration.sa.PafaSAOException;
import com.paic.pafa.appclient.IServiceClient;
import com.paic.pafa.appclient.ServiceParams;
import com.paic.pafa.appclient.ServiceResults;
import com.paic.pafa.appclient.annotation.ActionClient;
import com.paic.pafa.biz.sao.BaseSAO;

/**
 * 月度报告调用 FWA 接口辅助类
 * @author EX-CHENLIN600
 *
 */
@Component("fwaMonthlyReportSao")
public class FwaMonthlyReportSaoImpl extends BaseSAO implements FwaMonthlyReportSao {
	private Log log = LogFactory.getLog(FwaMonthlyReportSaoImpl.class);
	
	// 在不同weblogic下调用
//	 @ActionClient(name = "mhis.fwa.MedicalDeptCodeHonestyESA", pafaAc = "${mhis.fwa.pafaAc}")
	// 在同一个weblogic下调用
	@ActionClient(name = "mhis.fwa.MedicalDeptCodeHonestyESA", pafaAc = "${web.defaultPafaAcClient}")
	private IServiceClient serviceClient;
	
	@Override
	public List<Map<String, Object>> invokeMonthlyReportInfoESA(String medicalOrgCode,String month,String visitType)
			throws PafaSAOException {
		ServiceParams params = ServiceParams.newInstance();
		params.set("medicalOrgCode", medicalOrgCode);	//机构编码
		params.set("month", month);	//月份
		params.set("visitType", visitType);	//就诊类型:1为住院， 2为门诊
		//调用FWA接口
		ServiceResults result = serviceClient.invoke(params);
		log.info("===========FWA接口返回的数据========="+result);
		Map<String, Object> resList =  (Map<String, Object>) result.get("map");
		List<Map<String, Object>> list = (List<Map<String, Object>>) resList.get("deptList");
		return list;
	}

}
